import { ROOT_STORAGE_KEY, type StorageModel, type Settings } from '../types/model';
import * as shared from '../../../shared/storage.js';

// 统一错误提示文案
export const STORAGE_ERROR_MSG = '⚠️ 本地保存失败，请重试';

// TypeScript 壳层：委托给 shared/storage.js 的唯一实现，避免重复代码
export async function getRoot(): Promise<StorageModel | undefined> {
  return (await shared.getRoot()) as StorageModel | undefined;
}

export async function setRoot(data: StorageModel): Promise<void> {
  await shared.setRoot(data as any);
}

export async function patchRoot(patch: Partial<StorageModel>): Promise<void> {
  await shared.patchRoot(patch as any);
}

export function makeInitialData(): StorageModel {
  return shared.makeInitialData() as StorageModel;
}

export { ROOT_STORAGE_KEY };
